
* ---------------------------------------------------------------------------- *
* Do-file replicating Figure 2 in Asenjo, Escudero and Liepmann (2023)
* The do-file, data and graph files are all saved in one folder:

cd "[PLEASE INCLUDE FOLDER PATH]"

set more off
use "SSPTW_extracted_data.dta", clear

* ---------------------------------------------------------------------------- *

* ---------------------------------------------------------------------------- *
*** Merge country classifications
* rename for consistency
gen country_orig = country

replace country = "Bolivia, Plurinational State of" if country == "Bolivia"
replace country = "Brunei Darussalam" if country == "Brunei"
replace country = "Myanmar" if country == "Burma/Myanmar"
replace country = "Cape Verde" if country == "Cabo Verde"
replace country = "Côte d'Ivoire" if country == "Cote d'Ivoire"
replace country = "Iran, Islamic Republic of" if country == "Iran"
replace country = "Lao People's Democratic Republic" if country == "Laos"
replace country = "Micronesia, Federated States of" if country == "Micronesia"
replace country = "Moldova, Republic of" if country == "Moldova"
replace country = "Philippines" if country == "Phillippines"
replace country = "Russian Federation" if country == "Russia"
replace country = "Syrian Arab Republic" if country == "Syria"
replace country = "Sao Tome and Principe" if country == "São Tomé and Príncipe"
replace country = "Tanzania, United Republic of" if country == "Tanzania"
replace country = "Venezuela, Bolivarian Republic of" if country == "Venezuela" 
replace country = "Viet Nam" if country == "Vietnam"
replace country = "Congo" if country=="Congo, Republic of the"

					  
merge 1:1 country using "ILO regional groupings 2018.dta"
drop _merge

* ---------------------------------------------------------------------------- *

* ---------------------------------------------------------------------------- *
*** Merge regional coordinates to create maps
* rename for consistency
ren country NAME_LONG

replace NAME_LONG = "Bolivia"	if NAME_LONG == "Bolivia, Plurinational State of"
replace NAME_LONG = "Republic of Congo"	if NAME_LONG == "Congo"
replace NAME_LONG = "Democratic Republic of the Congo"	if NAME_LONG == "Congo, Democratic Republic of the"
replace NAME_LONG = "The Gambia"	if NAME_LONG == "Gambia"
replace NAME_LONG = "Hong Kong"	if NAME_LONG == "Hong Kong, China"
replace NAME_LONG = "Iran"	if NAME_LONG == "Iran, Islamic Republic of"
replace NAME_LONG = "Dem. Rep. Korea"	if NAME_LONG == "Korea, Democratic People's Republic of"
replace NAME_LONG = "Republic of Korea"	if NAME_LONG == "Korea, Republic of"
replace NAME_LONG = "Lao PDR"	if NAME_LONG == "Lao People's Democratic Republic"
replace NAME_LONG = "Macao"	if NAME_LONG == "Macau, China"
replace NAME_LONG = "Macedonia"	if NAME_LONG == "Macedonia, the former Yugoslav Republic of"
replace NAME_LONG = "Federated States of Micronesia"	if NAME_LONG == "Micronesia, Federated States of"
replace NAME_LONG = "Moldova"	if NAME_LONG == "Moldova, Republic of"
replace NAME_LONG = "Palestine"	if NAME_LONG == "Occupied Palestinian Territory"
replace NAME_LONG = "São Tomé and Principe"	if NAME_LONG == "Sao Tome and Principe"
replace NAME_LONG = "Syria"	if NAME_LONG == "Syrian Arab Republic"
replace NAME_LONG = "Taiwan"	if NAME_LONG == "Taiwan, China"
replace NAME_LONG = "Tanzania"	if NAME_LONG == "Tanzania, United Republic of"
replace NAME_LONG = "Venezuela"	if NAME_LONG == "Venezuela, Bolivarian Republic of"
replace NAME_LONG = "Vietnam"	if NAME_LONG == "Viet Nam"

merge 1:1 NAME_LONG using "worldmap.dta" 

* ---------------------------------------------------------------------------- *

* ---------------------------------------------------------------------------- *


* ---------------------------------------------------------------------------- *

* ---------------------------------------------------------------------------- *
*** Mapping.
*** Creating one map that conveys:
* (a) where do unemployment protection schemes exist? 
* (b) if they exist, do they include ALMPs (according to SSPTW data)? 

***  To increase readability of the Stata map, Antarctica is dropped. 
drop if NAME_LONG=="Antarctica"

*** Re-classify some high-income countries which we want to keep in the analysis, as justified in the Supplementary Material
tab NAME_LONG if incomegroup==4

foreach name in Argentina Chile Uruguay "French Guiana" Panama "Saudi Arabia" Qatar Kuwait "United Arab Emirates" Bahrain Oman {
replace incomegroup = 3 if NAME_LONG == "`name'"

}

* ---------------------------------------------------------------------------- *

* ---------------------------------------------------------------------------- *
*** Changes to "Malaysia", given that the 2018 data indicate a change compared to previous versions of the data.
replace almp_mentioned="Registration with employment office; vocational training and occupational training" if NAME_LONG=="Malaysia"
replace context_almp_mentioned="Qualifying conditions" if NAME_LONG=="Malaysia"
replace general_information="Social insurance system" if NAME_LONG=="Malaysia"
replace source="2018_Asia_Pacific" if NAME_LONG=="Malaysia"

* ---------------------------------------------------------------------------- *

* ---------------------------------------------------------------------------- *
*** first mapping_var: defines the type of social protection scheme. 
gen mapping_var = 5
* China: checked with soc. sec. report
replace mapping_var = 1 if general_information=="Local government administered social insurance programs"
replace mapping_var = 1 if general_information=="Social insurance and assistance system"
replace mapping_var = 1 if general_information=="Social insurance and mandatory individual account system"
replace mapping_var = 1 if general_information=="Social insurance and social assistance system"
replace mapping_var = 1 if general_information=="Social insurance and social assistance system."
replace mapping_var = 1 if general_information=="Social insurance system"
replace mapping_var = 1 if general_information=="Social insurance system in process of implementation"
replace mapping_var = 1 if general_information=="Social insurance system."
replace mapping_var = 1 if general_information=="Social insurance, and mandatory and voluntary individual account system"
replace mapping_var = 1 if general_information=="Unemployment insurance"


replace mapping_var = 2 if general_information=="Social assistance system"
replace mapping_var = 2 if general_information=="Subsistence income for the unemployed"

replace mapping_var = 3 if general_information=="Employmentrelated and mandatory individual account system"
replace mapping_var = 3 if general_information=="Mandatory individual account and employerliability system"
replace mapping_var = 3 if general_information=="Saving accounts"
replace mapping_var = 3 if general_information=="Savings accounts"

replace mapping_var = 4 if general_information=="No information on unemployment"
replace mapping_var = 4 if general_information=="No statutory benefits"
replace mapping_var = 4 if general_information=="No statutory benefits are provided; severance pay"
replace mapping_var = 4 if general_information=="No statutory benefits, severance pay mentioned"
replace mapping_var = 4 if general_information=="No statutory benefits; severance funds"
replace mapping_var = 4 if general_information=="No statutory benefits; severance pay mentioned"
replace mapping_var = 4 if general_information=="No statutory benefits; severance pay only"
replace mapping_var = 4 if general_information=="No statutory unemployment benefits; severance pay"
replace mapping_var = 4 if general_information=="Notice period or severance pay only"
replace mapping_var = 4 if general_information=="Public works programme"
replace mapping_var = 4 if general_information=="Remuneration of earnings prior to job loss"
replace mapping_var = 4 if general_information=="Severance pay only"
replace mapping_var = 4 if general_information=="Severance pay only; but also ALMPs"
replace mapping_var = 4 if general_information=="Severance pay; individual savings accounts"
replace mapping_var = 4 if general_information=="Unemployment only under old age, survivor, disability funds"
replace mapping_var = 4 if general_information=="No statutory benefits "
replace mapping_var = 4 if general_information=="No statutory unemployment benefits; severance pay "

replace mapping_var = 6 if incomegroup == 4

# del; 
la def mapping_var_lb 
1 "Soc. ins. alone or with soc. assistance"
2 "Social ass. only"
3 "Ind. saving accounts"
4 "No nat. legisl. or sev. pay only"
5 "Missing data"
6 "Excluded high-inc. countries" ;
# del cr

la val mapping_var mapping_var_lb

ren mapping_var unempl_scheme_detail
la var unempl_scheme_detail "Unempl prot scheme, 6 categories"

gen unempl_scheme_broad = .
replace unempl_scheme_broad = 1 if unempl_scheme_detail == 1 | unempl_scheme_detail == 2 | unempl_scheme_detail == 3 
replace unempl_scheme_broad = 2 if unempl_scheme_detail == 4
replace unempl_scheme_broad = 3 if unempl_scheme_detail == 5
replace unempl_scheme_broad = 4 if unempl_scheme_detail == 6

# del; 
la def unempl_scheme_broad_lb
1 "Ins. and/or assist. or ind. savings acc."
2 "No nat. legisl / sever pay only"
3 "Missing data"
4 "Excl. high-income countries" ;
# del cr

la val unempl_scheme_broad unempl_scheme_broad_lb
la var unempl_scheme_broad "Unempl prot scheme, 4 categories"

* ---------------------------------------------------------------------------- *

* ---------------------------------------------------------------------------- *
*** ALMP TYPES.
tab almp_mentioned, m
	
gen JP_service = 0
la var JP_service "Mandatory Registration / Job placement service"
foreach string in Registration registration registered Registered placement Register "Employment services" "employment promotion services" {
replace JP_service = regexm(almp_mentioned, "`string'") if JP_service==0

}
replace JP_service = 1 if NAME_LONG=="Marocco"	
* Changed after closer inspection of the case. 

gen training = 0
la var training "Training"
foreach string in training Workfare {
replace training = regexm(almp_mentioned, "`string'") if training==0

}

gen public_works = 0
la var public_works "Public works or subsidized empl."
foreach string in "Employment Guarantee" "Public works" "public works" "subsidized employment" {
replace public_works = regexm(almp_mentioned, "`string'") if public_works==0

}

gen start_up_support = 0
la var start_up_support "Start up support" 
foreach string in business "start-up capital" {
replace start_up_support = regexm(almp_mentioned, "`string'") if start_up_support==0

}


*** Combinations
gen mapping_var2 = .
replace mapping_var2 = 1 if JP_service==1 & training==0 & public_works==0
replace mapping_var2 = 2 if JP_service==0 & training==1 & public_works==0
replace mapping_var2 = 3 if JP_service==0 & training==0 & public_works==1
replace mapping_var2 = 4 if JP_service==1 & training==1 & public_works==0
replace mapping_var2 = 5 if JP_service==1 & training==0 & public_works==1
replace mapping_var2 = 6 if JP_service==1 & training==0 & public_works==0 & start_up_support==1
replace mapping_var2 = 7 if JP_service==1 & training==0 & public_works==1 & start_up_support==1

replace mapping_var2 = 10 if incomegroup==4
replace mapping_var2 = 9 if mapping_var2 == . & source==""
replace mapping_var2 = 8 if mapping_var2 == .

# del;
la def mapping_var2_lb 
1 "Job placement"
2 "Training"
3 "Publ. works / subsidized empl."
4 "Job placement + training"
5 "Job placement + publ. works"
6 "Job placement + start-up support"
7 "Job placement + start-up support + subs. empl." 
8 "No ALMP"
9 "No data"
10 "Excluded high-inc. countries" ;
la val mapping_var2 mapping_var2_lb ;
# del cr

ren mapping_var2 ALMP_comb_detail
la var ALMP_comb_detail "ALMP combinations, 10 categories"


*** Rearranage and simplify, as we cannot account for all possible cases in the maps. 
* Simplifications are as follows:
* Laos People's Dem. Republic: only training mentioned, but included under job placement and training
* Belarus: included under public works, but also includes job placement
* Romania: included under job placement + start-up support, but also includes subsidized employment
gen ALMP_comb_broad = 1 if ALMP_comb_detail == 4 | ALMP_comb_detail == 2
replace ALMP_comb_broad = 2 if ALMP_comb_detail == 1
replace ALMP_comb_broad = 3 if ALMP_comb_detail == 6 | ALMP_comb_detail == 7
replace ALMP_comb_broad = 4 if ALMP_comb_detail == 5 | ALMP_comb_detail == 3
replace ALMP_comb_broad = 5 if ALMP_comb_detail == 8
replace ALMP_comb_broad = 6 if ALMP_comb_detail == 9
replace ALMP_comb_broad = 7 if ALMP_comb_detail == 10

# del ;
la def ALMP_comb_broad_lb 
1 "Job Placement + Training"
2 "Job Placement Alone"
3 "Job Placement + Start-up support"
4 "Public Works"
5 "No ALMP"
6 "No Data"
7 "Excluded high-inc country" ;
# del cr
la val ALMP_comb_broad ALMP_comb_broad_lb

* ---------------------------------------------------------------------------- *

* ---------------------------------------------------------------------------- *
*** Bringing together the two mapping variables. 
tab unempl_scheme_broad ALMP_comb_broad, m

*** Check apparent inconsistencies: 
* Mozambique:  no unemployment protection scheme, no severance pay;  public works programme is mentioned
* Paraguay:    no unemployment protection scheme; severance pay, training and job placement are mentioned
* Philippines: no unemployment protection scheme; severance pay and job placement are mentioned

*** > Decision: consider those as ALMPs that are not integrated in an unemployment protection scheme, i.e., these are not integrated policies. 

* ---------------------------------------------------------------------------- *

* ---------------------------------------------------------------------------- *
*** Now putting the two variables together. 
* Job Placement alone comes first. 
gen map_var =.
replace map_var = 1 if unempl_scheme_broad==1 & ALMP_comb_broad==2
replace map_var = 2 if unempl_scheme_broad==1 & ALMP_comb_broad==1
replace map_var = 3 if unempl_scheme_broad==1 & ALMP_comb_broad==3 
replace map_var = 4 if unempl_scheme_broad==1 & ALMP_comb_broad==4  
replace map_var = 5 if unempl_scheme_broad==1 & ALMP_comb_broad==5 
replace map_var = 6 if unempl_scheme_broad==2
replace map_var = 7 if unempl_scheme_broad==3 | unempl_scheme_broad==4

# del ;
la def map_var_lb 
1 "Unempl Prot + PES alone"
2 "Unempl Prot + PES + Training"
3 "Unempl Prot + PES + Start-up sup."
4 "Unempl Prot + Public Works"
5 "Unempl Prot + No ALMP"
6 "No nat. legisl/Sever. pay only"
7 "No data/Excl. high-inc. country" 
11 "No data / Other inc. groups, excluded";
# del cr

* label no. 11 is added for later. 
la val map_var map_var_lb

*** Change Papua New Guinea after closer inspection of the case
replace map_var=5 if country=="Papua New Guinea" 

* ---------------------------------------------------------------------------- *

* ---------------------------------------------------------------------------- *
*** Define RGB colors for the different map categories (i.e., in line with map_var)
local map_var1 157 161 252
local map_var2 72 78 189
local map_var3 22 27 135
local map_var4 0 3 64
local map_var5 50 110 45
local map_var6 46 196 33
local map_var7  white
local map_var11 white

* ---------------------------------------------------------------------------- *

* ---------------------------------------------------------------------------- *
*** Display this in one map. 


spmap map_var using "worldcoord.dta" , id(id) /*
	*/ clmethod(unique) /*
	*/ ndfcolor(gs10) ndocolor(black)/*
    */ legend(pos(4) row(7) ring(4) size(*.95) symx(*.95) symy(*.95) forcesize)/*
	*/ title("Mandatory ALMPs included in unemployment protection schemes, by country and type of measure", style (Bold))/*
	*/ fcolor("`map_var1'" "`map_var2'" "`map_var3'" "`map_var4'" "`map_var5'" "`map_var6'" "`map_var7'")
	
       

graph export "almps_incl_in_unempl_protection1.pdf", replace

* ---------------------------------------------------------------------------- *

* ---------------------------------------------------------------------------- *
